<template>
	<view class="app">
		<view class="cell">
			<text class="tit fill">原密码</text>
			<input class="input" v-model="oldpay" type="password" maxlength="6" placeholder="支付密码，请输入6位数字" placeholder-style="color:#999;font-size:30rpx" />
		</view>
		<view class="cell">
			<text class="tit fill">新密码</text>
			<input class="input" v-model="pay" type="password" maxlength="6" placeholder="支付密码，请输入6位数字" placeholder-style="color:#999;font-size:30rpx" />
		</view>
		<view class="cell">
			<text class="tit fill">确认密码</text>
			<input class="input" v-model="repay" type="password" maxlength="6" placeholder="支付密码，请输入6位数字" placeholder-style="color:#999;font-size:30rpx" />
		</view>
		<button class="add-btn" style="background: #0066FF;color: #FFFFFF;margin:50px 15px"  @click="confirm('add')">提交</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				showPwd: false,
				oldpay: '',
				pay: '',
				repay: ''
			}
		},
		methods: {
			async confirm() {
				let {
					oldpay,
					pay,
					repay
				} = this;
				let parms = {
					oldpay,
					pay,
					repay
				}
				if (!oldpay) {
					this.$fun.msg('请输入原密码')
					return
				}
				if (!pay) {
					this.$fun.msg('请输入新密码')
					return
				}
				if (!repay) {
					this.$fun.msg('请输入确认新密码')
					return
				}
				if (repay != pay) {
					this.$fun.msg('两次密码输入不一致')
					return
				}
				await this.$fun.ajax.post('user/editPay',{ ...parms
				}).then(res => {
					if (res.code == 1) {
						this.$fun.msg(res.msg)
						setTimeout(()=>{
							uni.navigateBack({
							
							})
						},1000)
					}
				})
			},
			changePwdState() {
				this.showPwd = !this.showPwd;
			}
		}
	}
</script>

<style scoped lang="scss">
	.app {
		padding-top: 30rpx;
	}

	.cell {
		display: flex;
		align-items: center;
		min-height: 110rpx;
		margin: 0 40rpx;
		border-bottom: 1px solid rgb(236, 236, 236);

		&:first-child {
			margin-bottom: 10rpx;
		}

		&:after {
			left: 40rpx;
			right: 40rpx;
			border-color: #d8d8d8;
		}

		.tit {
			font-size: 30rpx;
			color: #333;
		}

		.avatar-wrap {
			width: 120rpx;
			height: 120rpx;
			position: relative;
			border-radius: 100rpx;
			overflow: hidden;

			.avatar {
				width: 100%;
				height: 100%;
				border-radius: 100rpx;
			}

			.progress {
				position: absolute;
				left: 50%;
				top: 50%;
				transform: translate(-50%, -50%);
				width: 100rpx;
				height: 100rpx;
				box-shadow: rgba(0, 0, 0, .6) 0px 0px 0px 2005px;
				border-radius: 100rpx;
				transition: .5s;
				opacity: 0;

				&.no-transtion {
					transition: 0s;
				}

				&.show {
					opacity: 1;
				}
			}
		}

		.input {
			flex: 1;
			text-align: right;
			font-size: 28rpx;
			color: #333;
		}

		switch {
			margin: 0;
			transform: scale(0.8) translateX(10rpx);
			transform-origin: center right;
		}

		.tip {
			margin-left: 20rpx;
			font-size: 28rpx;
			color: #999;
		}

		.checkbox {
			padding: 12rpx 0 12rpx 40rpx;
			font-size: 28rpx;
			color: #333;

			.mix-icon {
				margin-right: 12rpx;
				font-size: 36rpx;
				color: #ccc;
			}

			.icon-xuanzhong {
				color: $base-color;
			}
		}
	}
</style>
